export const SET_TAG = 'SET_TAG'


export interface ActionType {
	type: typeof SET_TAG
	payload: any
}

export interface TagType {
	name: string
}

export interface State {
	tag: TagType[]
}

const initState: State = {
	tag: JSON.parse(localStorage.getItem('tag') || '[]')
}

const reducer = (state = initState, action: ActionType) => {
	switch (action.type) {
		case 'SET_TAG':
			return {
				...state,
				tag: action.payload
			}
		default:
			return {
				...state
			}
	}
}

export default reducer